#include<stdio.h>
#include<string.h>

void Plus(char num1[],char num2[],char ans[],int length1,int length2);
int main(void)
{
	int T;
	char num1[1000],num2[1000],ans[1000];
	
	scanf("%d",&T);
	
	int length1,length2,length;
	for(int i=0;i<T;i++)
	{
		scanf("%s%s",num1,num2);
		
		length1=strlen(num1);
		length2=strlen(num2);
		
		Plus(num1,num2,ans,length1,length2);
		length=strlen(ans);
		for(int i=length-1;i>=0;i--)
		{
			printf("%c",ans[i]);
		}
		putchar('\n');
	}
	
	return 0;
}
void Plus(char num1[],char num2[],char ans[],int length1,int length2)
{
	char temp;
	for(int i=0;i<length1/2;i++)
	{
		temp=num1[i];
		num1[i]=num1[length1-i-1];
		num1[length1-i-1]=temp;
	}
	for(int j=0;j<length2/2;j++)
	{
		temp=num2[j];
		num2[j]=num2[length2-j-1];
		num2[length2-j-1]=temp;
	}
	int num,k=0,up=0,i_plus=1,j_plus=1;
	for(int i=0,j=0;num1[i]!='\0'||num2[j]!='\0';)
	{
		if(num1[i]=='\0')
		{
			i_plus=0;
		}
		if(num2[j]=='\0')
		{
			j_plus=0;
		}
		
		num=(int)(num1[i]+num2[j]);
		
		
		if(i_plus==0||j_plus==0)
		{
			num+=48;
		}
		if(up==1)
		{
			num+=1;
		}
		switch(num)
		{
			case 96:ans[k]='0';up=0;break;
			case 97:ans[k]='1';up=0;break;
			case 98:ans[k]='2';up=0;break;
			case 99:ans[k]='3';up=0;break;
			case 100:ans[k]='4';up=0;break;
			case 101:ans[k]='5';up=0;break;
			case 102:ans[k]='6';up=0;break;
			case 103:ans[k]='7';up=0;break;
			case 104:ans[k]='8';up=0;break;
			case 105:ans[k]='9';up=0;break;
			case 106:ans[k]='0';up=1;break;
			case 107:ans[k]='1';up=1;break;
			case 108:ans[k]='2';up=1;break;
			case 109:ans[k]='3';up=1;break;
			case 110:ans[k]='4';up=1;break;
			case 111:ans[k]='5';up=1;break;
			case 112:ans[k]='6';up=1;break;
			case 113:ans[k]='7';up=1;break;
			case 114:ans[k]='8';up=1;break;
			case 115:ans[k]='9';up=1;
		}
		if(i_plus==1&&j_plus==1)
		{
			i++;
			j++;
		}
		else if(i_plus==0)
		{
			j++;
		}
		else if(j_plus==0)
		{
			i++;
		}
		k++;
	}
	if(up==1)
	{
		ans[k]='1';
		ans[k+1]='\0';
	}
	else
	{
		ans[k]='\0';
	}
}
